//
//  OPEatDetailHeadView.m
//  OnePiece
//
//  Created by wsy on 15/10/28.
//  Copyright © 2015年 wsy. All rights reserved.
//

#import "OPEatDetailHeadView.h"
#import <UIImageView+WebCache.h>
@implementation OPEatDetailHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if ( self) {
        self.backgroundColor = [UIColor colorWithRed:1.000 green:0.985 blue:0.971 alpha:1.000];
        _picture = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH*235/600)];
        [self addSubview:_picture];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH*235/600)];
        view.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.708];
        [self addSubview:view];
        _title = [[UILabel alloc]initWithFrame:CGRectMake(20, SCREEN_WIDTH*235/600/2-20, SCREEN_WIDTH - 60, 60)];
        _title.numberOfLines = 0;
        _title.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:18];
        _title.textColor = [UIColor whiteColor];
        [self addSubview:_title];
        _icon = [[UIImageView alloc]initWithFrame:CGRectMake(20, SCREEN_WIDTH*235/600-35, 30, 30)];
        _icon.layer.cornerRadius = 15;
        _icon.layer.masksToBounds = YES;
        [self addSubview:_icon];
        _uname = [[UILabel alloc]initWithFrame:CGRectMake(55, SCREEN_WIDTH*235/600-35, 120, 30)];
        _uname.font = [UIFont systemFontOfSize:12];
        _uname.textColor = [UIColor whiteColor];
        [self addSubview:_uname];
        _city = [[UILabel alloc]initWithFrame:CGRectMake(20, SCREEN_WIDTH*235/600+10, 80, 20)];
        _city.font = [UIFont systemFontOfSize:12];
        _city.textColor = [UIColor colorWithWhite:0.412 alpha:1.000];
        [self addSubview:_city];
        _time = [[UILabel alloc]initWithFrame:CGRectMake(100, SCREEN_WIDTH*235/600+40, 120, 20)];
        _time.font = [UIFont systemFontOfSize:12];
        _time.textColor = [UIColor colorWithWhite:0.412 alpha:1.000];
        [self addSubview:_time];
        _rest = [[UILabel alloc]initWithFrame:CGRectMake(100, SCREEN_WIDTH*235/600+10, 180, 20)];
        _rest.font = [UIFont systemFontOfSize:12];
        _rest.textColor = [UIColor colorWithWhite:0.412 alpha:1.000];
        [self addSubview:_rest];
        _cost = [[UILabel alloc]initWithFrame:CGRectMake(20, SCREEN_WIDTH*235/600+40, 80, 20)];
        _cost.font = [UIFont systemFontOfSize:12];
        _cost.textColor = [UIColor colorWithWhite:0.412 alpha:1.000];
        [self addSubview:_cost];
    }
    return self;
}

-(void)setConfigureModel:(OPEatDetailMainModel *)configureModel{
    [_picture sd_setImageWithURL:[NSURL URLWithString:configureModel.cover] placeholderImage:[UIImage imageNamed:@"beijingImg.jpg"]];
    _title.text = configureModel.title;
    [_icon sd_setImageWithURL:[NSURL URLWithString:configureModel.author[@"header"]] placeholderImage:[UIImage imageNamed:@"beijingImg.jpg"]];
    NSLog(@"%@",configureModel.author);
    _uname.text = configureModel.author[@"uname"];
    _city.text = [NSString stringWithFormat:@"城市：%@",configureModel.city];
    _time.text = [NSString stringWithFormat:@"时间：%@",configureModel.ctime];
    _rest.text = [NSString stringWithFormat:@"餐厅：%@",configureModel.rest];
    _cost.text = [NSString stringWithFormat:@"人均：%@",configureModel.cost];
}

@end
